<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>特殊消费用户管理</title>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery/jquery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/plupload/plupload.full.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery/jquery-ui/jquery-ui.js"></script>

<script
	src="${pageContext.request.contextPath}/js/bootstrap/bootstrap.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/table/bootstrap-table.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/table/locale/bootstrap-table-zh-CN.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/table/plugins/tableExport.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/table/plugins/table-export.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/table/plugins/jquery.base64.js"
	type="text/javascript"></script>

<script src="${pageContext.request.contextPath}/ui/layui/layui.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/layui/lay/modules/laydate.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/layui/lay/modules/layer.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/ui/layui/lay/modules/form.js"
	type="text/javascript"></script>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/layui/css/modules/laydate/laydate.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/jquery-css/jquery-ui.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap-css/bootstrap.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/table/bootstrap-table.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/layui/css/layui.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/layui/css/global.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/layui/css/modules/layer/default/layer.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/ui/layui/css/modules/code.css">


<style>
.container {
	width: 85%;
}

.modal-company {
	width: 700px;
}

.modal-body {
	max-height: 750px
}

.modal-body-company {
	height: 600px;
}

.modal-account {
	width: 400px;
	z-index: 2000;
	left: 65%;
}

.modal-account.fade.in {
	top: 15%;
}

.modal-body-account {
	height: 200px;
}
</style>

</head>

<body>
	<%@include file="/webpage/frame/top.jsp"%>
	<div class="container">

		<div class="layui-form-pane" style="margin-top: 15px;"></div>



		<table id="inversetable" data-show-refresh="true" data-search="true"
			data-click-to-select="true" data-show-export="true"
			data-query-params="queryParams" data-pagination="true"
			data-toolbar=".toolbar">
			<!-- data-show-columns="true"  -->
			<thead>
				<tr>
					<th data-field="state" data-radio="true"></th>
					<th data-field="companyId" data-sortable="true">公司id</th>

					<th data-field="companyName" data-sortable="true">公司名称</th>
					<th data-field="industryName" data-sortable="true">行业名称</th>
					<th data-field="companyLabel" data-sortable="true">标签</th>
					<th data-field="action" data-align="center"
						data-formatter="actionFormatter" data-events="actionEvents">操作</th>








				</tr>
			</thead>

		</table>
	</div>



	<script>
		var API_URL = '${pageContext.request.contextPath}/specialCompanyController.do?getCompanys';

		//获取加载公司列表
		var $table = $('#inversetable').bootstrapTable({
			url : API_URL,
			pageSize : 25,
			pageList : [ 15, 25, 100, 500 ]
		}

		);

		function actionFormatter(value, row, index) {
			buttonArray = new Array();

			if (row.companyLabel == '特殊消费用户') {
				buttonArray[0] = '<a class="signGeneral btn btn btn-default" href="javascript:" title="标记普通">标记普通</a>';

			} else {
				buttonArray[0] = '<a class="signSpecial btn btn btn-default" href="javascript:" title="标记特殊">标记特殊</a>';
			}

			return buttonArray.join(' ');
		}
		window.actionEvents = {
			'click .signGeneral' : function(e, value, row) {
				 if (confirm('确定要标记为普通吗?')) {
                     $.ajax({
                         url:  '${pageContext.request.contextPath}/specialCompanyController.do?signGeneral',
                         type: 'post',
                         data:{companyId: row.companyId
                         	     },
                         success: function (result) {
                        	 var data = $.parseJSON(result);	
                        	 alert(data);
                             $table.bootstrapTable('refresh');
                             
                         },
                         error: function () {
                        	 alert("标记失败");
                         }
                     })
                            	              	 
           }
			},
			'click .signSpecial' : function(e, value, row) {
				 if (confirm('确定要标记为特殊吗?')) {
                     $.ajax({
                         url:  '${pageContext.request.contextPath}/specialCompanyController.do?signSpecial',
                         type: 'post',
                         data:{companyId: row.companyId,
                        	 companyName:row.companyName,
                        	 industryName:row.industryName,
                        	 
                         	     },
                         success: function (result) {
                        		var data = $.parseJSON(result);	
                        	 alert(data);
                             $table.bootstrapTable('refresh');
                             
                         },
                         error: function () {
                        	 alert("标记失败");
                         }
                     })
                            	              	 
           }
			},
		}
	</script>

</body>
</html>